﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AR.Entities;
using AR.ViewModels.Commands;
using System.Collections.ObjectModel;
using AR.Model;
using System.ServiceModel.DomainServices.Client;
using AR.Web;
using AR.CustomEntities;
namespace AR.ViewModels
{
    public class EntretienOraleViewModel : ViewModelBase
    {
        #region Attributs
        private readonly CandidatModel model;
        private ObservableCollection<CANDIDAT> _candidats;
        public ObservableCollection<CANDIDAT> Candidats
        {
            get
            {
                return _candidats;
            }
            set
            {
                if (value != _candidats)
                {
                    _candidats = value;
                    OnPropertyChanged("Candidats");
                }
            }
        }

        private ObservableCollection<CANDIDAT> _candidatsResultatEntretien;
        public ObservableCollection<CANDIDAT> CandidatsResultatEntretien
        {
            get
            {
                return _candidatsResultatEntretien;
            }
            set
            {
                if (value != _candidats)
                {
                    _candidatsResultatEntretien = value;
                    OnPropertyChanged("CandidatsResultatEntretien");
                }
            }
        }
        #endregion

        #region Entity State Events 
        private void OnEntityAdded(object sender, EntityCollectionChangedEventArgs<CANDIDAT> entityCollectionChangedEventArgs)
        {
            Candidats.Add(entityCollectionChangedEventArgs.Entity);
        }
        private void OnEntityAdded2(object sender, EntityCollectionChangedEventArgs<CANDIDAT> entityCollectionChangedEventArgs)
        {
            CandidatsResultatEntretien.Add(entityCollectionChangedEventArgs.Entity);
        }
        private void OnEntityRemoved(object sender, EntityCollectionChangedEventArgs<CANDIDAT> entityCollectionChangedEventArgs)
        {
            Candidats.Remove(entityCollectionChangedEventArgs.Entity);
        }
        private void OnEntityRemoved2(object sender, EntityCollectionChangedEventArgs<CANDIDAT> entityCollectionChangedEventArgs)
        {
            Candidats.Remove(entityCollectionChangedEventArgs.Entity);
        }
        #endregion

        public EntretienOraleViewModel()
        {
            model = new CandidatModel();
            CandidatModel model2 = new CandidatModel();
            Candidats = new ObservableCollection<CANDIDAT>();
            CandidatsResultatEntretien = new ObservableCollection<CANDIDAT>();
            model.GetCandidatsEntretien().EntityRemoved += OnEntityRemoved;
            model.GetCandidatsEntretien().EntityAdded += OnEntityAdded;
            model2.GetCandidatsResultat().EntityAdded += OnEntityAdded2;
        }

       
     
        public ICommand entretienOralCandidatCommand
        {
            get
            {
                return new EntOraleCandidat(this);
            }
        }
        public void getEntOraleCandidat(int idcandidat)
        {
         
            //this.NavigationService.Navigate(new Uri(String.Format
            //    ("Detail/{0}", idcandidat.ToString()), UriKind.Relative));
            //(Application.Current.RootVisual as ApplicationFrame).Navigate(new Uri("/Mainpage.xaml", UriKind.Relative));
        }

    }
}
